/**
 * 发布感谢视频
 * @parma content: 感谢文字, 可不传
 */
function thankVideo(videoPath, orderId, goodsId, goodsName, toId, content, imgUrl, success) {
  // 上传视频
  getApp().func.UploadFile([videoPath], 0, 0, 0, function (data) {
    // 上传成功返回url
    console.log('aaaa' + data);
    let files = {
      video: data[0]
    };
    if (imgUrl != null) {
      files = {
        video: data[0],
        img: imgUrl
      }
    }
    let param = new Object();
    param['orderId'] = orderId;
    param['goodsId'] = goodsId;
    param['goodsName'] = goodsName;
    param['fromId'] = getApp().globalData.userId;
    param['toId'] = toId;
    param['content'] = content;
    param['files'] = [files];
    // 新增
    getApp().func.Post(true, getApp().api.add_story, param,
      function (data) {
        typeof success == "function" && success(data);
      });
  },
    function () {
      console.log('bbbb');
    });
}

/**
 * 收到宝贝查询
 */
function receiveGoods(startPage, videoType, callback) {
  let param = new Object();
  param['startPage'] = startPage;
  param['type'] = videoType;
  param['userId'] = getApp().globalData.userId;
  getApp().func.Post(false, getApp().api.story_list, param, function (data) {
    callback(data);
  });
}

/**
 * 轮播列表
 * 1：首页轮播图，2：拼团列表顶部轮播图，3：感谢卡
 */
function getThankCardList(picType, callback) {
  let param = new Object();
  param['type'] = picType;
  getApp().func.Post(false, getApp().api.pic_settings, param, function (data) {
    callback(data); 
  })
}

module.exports = {
  thankVideo: thankVideo,
  receiveGoods: receiveGoods,
  getThankCardList: getThankCardList
}